import { Form, Input, InputNumber, Radio, Select } from 'antd';
import { useState } from 'react';
import an58 from '@mmstudio/an000058';
import EditButton from '../../../components/editbutton';
import { Message as M1, Result as R1 } from '../../api/project/edit.api';
import api from '../../../atoms/api';


export default function Edit({ data }: {
	data: M1;
}) {
	const [d, setd] = useState(data);
	return <>
		<EditButton dlgtitle='修改项目' onSave={async () => {
			if (!d
				|| !d.projectintroduction
			) {
				return '缺少必要的参数';
			}
			const res = await an58<R1, M1>(api['/api/project/edit'], 'post', d);
			if (res.ok === true) {
				return true;
			}
			return res.message;
		}}>
			{/* <Form.Item required label="年级:">
				<Input placeholder='请输入年级' value={d.grade} onChange={(e) => {
					setd({
						...d,
						grade: e.target.value
					});
				}} /></Form.Item>
			<Form.Item required label="班级名称:">
				<Input placeholder='xxx' value={d.classnumber} onChange={(e) => {
					setd({
						...d,
						classnumber: e.target.value
					});
				}} /></Form.Item>
			<Form.Item required label="团队编号:">
				<InputNumber min={0} placeholder='请输入团队编号' value={d.teamnumber} onChange={(e) => {
					setd({
						...d,
						teamnumber: e
					});
				}} />
			</Form.Item>
			<Form.Item required label="项目名称:">
				<Select
					optionFilterProp="children"
					filterOption={(input, option) => {
						return option.children.indexOf(input) >= 0;
					}}
					placeholder='请选择项目名称'
					value={d.projectnumber}
					onChange={(e) => {
						setd({
							...d,
							projectnumber: e
						});
					}} >
					{project.map((it) => {
						return <Select.Option key={it.projectnumber} value={it.projectnumber} >{it.projectname}</Select.Option>;
					})}
				</Select>
			</Form.Item>
			<Form.Item required label="团队名称:">
				<Input placeholder='请输入团队名称' value={d.teamname} onChange={(e) => {
					setd({
						...d,
						teamname: e.target.value
					});
				}} />
			</Form.Item>
			<Form.Item required label="项目负责人:">
				<Input placeholder='请输入项目负责人' value={d.projectleader} onChange={(e) => {
					setd({
						...d,
						projectleader: e.target.value
					});
				}} />
			</Form.Item> */}
			{/* <Form.Item required label="项目简介:">
				<Input.TextArea rows={4} placeholder='请输入项目简介' value={d.projectintroduction} onChange={(e) => {
					setd({
						...d,
						projectintroduction: e.target.value
					});
				}} />
			</Form.Item> */}
		</EditButton>
	</>;
}
